<template>
	<view class="demo">
		<view class="item" v-for="item in props.data" :key="item.id" :style="item.status === 6 ? 'color:#ababab;' : ''" @click="guestDetail(item)">
			<view class="top">
				<text>{{ item.address }}</text>
				<unitagVue v-if="item.status == 1" title="认证成功" :bgColor="backgroundColor1" :textColor="textColor1" />
				<unitagVue v-else-if="item.status == 2" title="认证中" :bgColor="backgroundColor2" :textColor="textColor2" />
				<unitagVue v-else-if="item.status == 3" title="认证失败" :bgColor="backgroundColor3" :textColor="textColor3" />
				<unitagVue v-else-if="item.status == 4" title="生效中" :bgColor="backgroundColor1" :textColor="textColor1" />
				<unitagVue v-else-if="item.status == 5" title="待生效" :bgColor="backgroundColor2" :textColor="textColor2" />
				<unitagVue v-else-if="item.status == 6" title="已失效" :bgColor="backgroundColor4" :textColor="textColor4" />
			</view>
			<view class="info" v-if="item.room">
				<view class="person">
					<text class="prefix">房间号</text>
					<text>{{ item.room }}</text>
				</view>
				<view class="person">
					<text class="prefix">业主</text>
					<text>{{ item.owner }}</text>
				</view>
				<view class="person">
					<text class="prefix">房间状态</text>
					<text>{{ item.type }}</text>
				</view>
			</view>
			<view class="info" v-else-if="item.guestName">
				<view class="person">
					<text class="prefix">访客姓名</text>
					<text>{{ item.guestName }}</text>
				</view>
				<view class="person">
					<text class="prefix">访问日期</text>
					<text>{{ item.guestDate }}</text>
				</view>
				<view class="person">
					<text class="prefix">访问时长</text>
					<text>{{ item.guestTimer }}</text>
				</view>
			</view>
			<view class="stall" v-else>
				<view class="stall_top">
					<view class="left">
						<view class="person">
							<text class="prefix">车位楼层</text>
							<text>{{ item.stallFloor }}</text>
						</view>
						<view class="person">
							<text class="prefix">车位编号</text>
							<text>{{ item.stallNumber }}</text>
						</view>
					</view>
					<view class="right">
						<view class="person">
							<text class="prefix">车位区域</text>
							<text>{{ item.stallArea }}</text>
						</view>
						<view class="person">
							<text class="prefix">车位状态</text>
							<text>{{ item.stallType }}</text>
						</view>
					</view>
				</view>
				<view class="bottom">
					<view class="person">
						<text class="prefix">绑定车辆</text>
						<text>{{ item.binding }}</text>
					</view>
				</view>
			</view>
		</view>
		<buttonVue v-if="props.title !== 'none'" :title="props.title" />
	</view>
</template>

<script setup>
import { ref } from 'vue';
import unitagVue from '@/components/tag.vue';
import buttonVue from '@/components/button.vue';
const props = defineProps(['data', 'title']);
const backgroundColor1 = ref('#d4f6e3');
const textColor1 = ref('#2edac0');
const backgroundColor2 = ref('#ffe9d7');
const textColor2 = ref('#ff9180');
const backgroundColor3 = ref('#fde0e0');
const textColor3 = ref('#f5638b');
const backgroundColor4 = ref('#f2f2f2');
const textColor4 = ref('#cdcdcd');
const guestDetail = (item) => {
	if (item.guestName) {
		uni.navigateTo({
			url: '/pages/guestDetail/guestDetail?id='+item.id
		});
	}
};
</script>

<style lang="scss">
.demo {
	width: 100%;
	height: 100%;
	box-sizing: border-box;
	padding: 0 30rpx;
	background-color: #fff;
	overflow: auto;
	.item {
		display: flex;
		flex-direction: column;
		justify-content: space-around;
		box-sizing: border-box;
		padding: 0 30rpx;
		border: 2rpx solid #f2f2f2;
		border-radius: 10rpx;
		margin: 30rpx 0;
		.top {
			height: 100rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 2rpx solid #f2f2f2;
		}
		.info {
			height: 220rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			.person {
				display: flex;
				align-items: center;
			}
			.prefix {
				width: 150rpx;
				color: #9a9a9a;
				margin-right: 20rpx;
			}
		}
		.stall {
			height: 220rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			.stall_top {
				height: 120rpx;
				display: flex;
				.left {
					width: 45%;
					display: flex;
					flex-direction: column;
					justify-content: space-around;
					.person {
						.prefix {
							width: 150rpx;
							color: #9a9a9a;
							margin-right: 20rpx;
						}
					}
				}
				.right {
					width: 45%;
					display: flex;
					flex-direction: column;
					justify-content: space-around;
					.person {
						.prefix {
							width: 150rpx;
							color: #9a9a9a;
							margin-right: 20rpx;
						}
					}
				}
			}
			.bottom {
				height: 80rpx;
				.person {
					.prefix {
						width: 150rpx;
						color: #9a9a9a;
						margin-right: 20rpx;
					}
				}
			}
		}
	}
}
</style>
